
<!DOCTYPE html>
<!-- release v4.4.7, copyright 2014 - 2018 Kartik Visweswaran -->
<!--suppress JSUnresolvedLibraryURL -->
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>新建事件</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
  <link rel="stylesheet" href="css/adminlte.min.css">
    <link rel="stylesheet" href="css/dropzone.css" />
    <link rel="stylesheet" href="bower_components/layer/layer.css" />
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
     <link rel="stylesheet" href="css/select2.css" />
    <script type="text/javascript" src="js/dropzone.js" ></script>
     <script src="bower_components/layer/layer.js"></script><!--[if IE]>
     	
     <![endif]-->
     <script src="bower_components/select2/dist/js/select2.full.min.js"></script>
     <script src="js/jq.cookie.js"></script>

</head>
<style>
	body {font-family: "Microsoft YaHei","iconfont"  !important;}
	.open_form{
		width: 550px;
		height: 350px;
		text-align: center;
		margin:auto;
	}
	label{
		display: inline-block;
		margin-right: 20px;
		}
	textarea{
		width:70%;
		height: 150px;
		overflow: auto;
		vertical-align: middle;
		margin-left:20px;
	}
.dropzone{
	border:2px dashed skyblue;
	border-radius:10px;
	width:500px;
	margin:auto;
}	
.ui.fluid.search.dropdown{
	width:70%;
	display: inline-block;
	margin-left:20px;
}	
.btn_box button{
	width: 100px;
	height: 30px;
	border: none;
}
.form-control{
	display: inline-block;
	width: 387px;
	
	
}
.select2-container{
margin-left: 20px;	
text-align: left;
}
</style>
<body>
	<div class="open_form">
		<div style="margin-top:20px;">
			<label>客户名称:</label>
<select class="select2 form-control" id="CstmMenu">
	
</select><br />
</div>
<div style="margin-top:20px;width:100%;position: relative;">
			<label> 项目名称:</label>
<select class="select2 form-control" id="ProjectMenu">
	
</select><br />
</div>
<div style="margin-top:20px;width:100%;">
			<label>批注内容:</label>
			<textarea class="mark_cont" id="Content"></textarea><br />
</div>
<div style="margin-top:20px;width:100%;">
			<label>批注类型:</label>
		
<select class="select2 form-control" id="KindMenu">
					<option value="发样">发样</option>
					<option value="扶持">扶持</option>
					<option value="预定">预定</option>
					<option value="推广">推广</option>
					<option value="纠纷">纠纷</option>
					<option value="销售反馈">销售反馈</option>
					<option value="其他">其他</option>	
</select>
</div>
</div>
    <form id ="myDropzone" action="http://www.duoweish.com/apis/EventPicUpload/" class="dropzone" method="POST">        
       <div class="fallback">
            <input name="file" type="file" multiple />
        </div> 
        <input id="Event" name="Event" type="text" style="display:none;" value="" />
        <input id="PicFlag" name="PicFlag" type="text" style="display:none;" value="0" />
    </form>
	<div class="btn_box" style="margin-top:20px;width:100%;text-align: center;">
		<button type="button" class="ui button" style="background: #3c8dbc;color: white;cursor: pointer;width: 100px;" id="Save">提交</button>
    	<button type="button" class="ui button" style="cursor: pointer;width: 100px;" id="Del">删除</button>
    </div>
    <div style="width:100%;height:20px;border: 1px solid transparent;">
    </div>
</body>
<script>
	$('.select2').select2()
 $(document).ready(function() {
 	$('#CstmMenu').change(function() {
		$.ajax({
			type:"get",
			url:"http://www.duoweish.com/apis/CstmJudge/",
			async:true,
			data:{
				Cstm:$('#CstmMenu').val() ,
			},
			success:function(data){
				if(data == "True"){
					$("#KindMenu").empty();
					$("#KindMenu").append("<option value='报价单'>报价单</option>");
					$("#KindMenu").append("<option value='三表存档'>三表存档</option>");
					$("#KindMenu").append("<option value='特殊情况'>特殊情况</option>");
					$("#KindMenu").append("<option value='签合同'>签合同</option>");
					$("#KindMenu").append("<option value='会议记录'>会议记录</option>");
					$("#KindMenu").append("<option value='贸易条款变更'>贸易条款变更</option>");
					$("#KindMenu").append("<option value='索要资料'>索要资料</option>");
					$("#KindMenu").append("<option value='给出反馈'>给出反馈</option>");
					$("#KindMenu").append("<option value='资源支持'>资源支持</option>");
				}else{
					$("#KindMenu").empty();
					$("#KindMenu").append("<option value='发样'>发样</option>");
					$("#KindMenu").append("<option value='扶持'>扶持</option>");
					$("#KindMenu").append("<option value='预定'>预定</option>");
					$("#KindMenu").append("<option value='推广'>推广</option>");
					$("#KindMenu").append("<option value='纠纷'>纠纷</option>");
					$("#KindMenu").append("<option value='销售反馈'>销售反馈</option>");
					$("#KindMenu").append("<option value='其他'>其他</option>");										
				}
				},
		}) 
 	});
 	});
 //两种配置方式，第一种，表单上传时的配置方式，可以打开form表单的注释，myAwesomeDropzone是表单的id
    Dropzone.options.myDropzone = {
          paramName: "file", // The name that will be used to transfer the file
          maxFilesize: 5, // MB
          maxFiles: 5,
          parallelUploads: 5,
          autoProcessQueue: false,
   		  init: function() {
    		  		var submitButton = document.querySelector("#Save")
       			myDropzone = this; // closure
    				submitButton.addEventListener("click", function() {
							$.ajax({
								type:"get",
								url:"http://www.duoweish.com/apis/NewEvent/",
								async:false,
								data:{
									UserId:$.cookie('ID'),
									Cstm:$('#CstmMenu').select2('val') ,
									Project: $('#ProjectMenu').select2('val'),
									Kind: $('#KindMenu').select2('val') ,
									Content: $("#Content").val()
								},
								success:function(data){
									if($('#PicFlag').val() == "1"){
										$('#Event').val(data);
										myDropzone.processQueue();										
									}else{
	                						layer.msg('上传成功');
                							myDropzone.removeAllFiles(true);
                							$('#Content').val("");									
									}

								},

							})    					
    				});
     		  		var DelButton = document.querySelector("#Del")
     				DelButton.addEventListener("click", function() {
      					myDropzone.removeAllFiles(true); // Tell Dropzone to process all queued files.
    					}); 
    				this.on("queuecomplete",function(file) {
                //上传完成后触发的方法
                		layer.msg('上传成功');
                		myDropzone.removeAllFiles(true);
                		$('#Content').val("");
            		});
            		this.on("addedfile", function(file) {
            			$('#PicFlag').val('1');
        			});
  }         
    };
    
$(document).ready(function () {
	var Event ;
        	$.ajax({
			type:"get",
			url:"http://www.duoweish.com/apis/SalesInfo/",
			success:function(data){
				for (var i = 0;i<data[0].length;i++) {
						$("#CstmMenu").append('<option value="'+ data[0][i] +'">'+ data[0][i] + '</option>'); 
				}
				for (var i = 0;i<data[1].length;i++) {
						$("#ProjectMenu").append('<option value="'+ data[1][i] +'">'+ data[1][i] + '</option>'); 
				}
			}
		});

    });
</script>
</html>